package com.lm.ddd.application;

import com.lm.ddd.domain.model.Order;
import com.lm.ddd.domain.repository.OrderRepository;

public class OrderService {
    private final OrderRepository orderRepository;

    public OrderService(OrderRepository orderRepository) {
        this.orderRepository = orderRepository;
    }

    // 应用服务提供支付订单的用例
    public void payOrder(String orderId) {
        Order order = orderRepository.findById(orderId);
        if (order == null) {
            throw new IllegalArgumentException("订单不存在");
        }
        order.pay();
        orderRepository.save(order);
    }
}